﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FirstFloor.ModernUI.Presentation;
using Kaesoft.Caja.LogicaNegocio;

namespace Kaesoft.Caja.Views.Pages
{
    /// <summary>
    /// Interaction logic for Comprobantes.xaml
    /// </summary>
    public partial class Comprobantes : UserControl
    {
        CajaParametrizacion logica = new CajaParametrizacion();
        public LinkCollection Menu { get; set; }      
        public Comprobantes()
        {
            InitializeComponent();
            Loaded += Comprobantes_Loaded;
        }

        void Comprobantes_Loaded(object sender, RoutedEventArgs e)
        {
            var data = this.GetType();
            var codigoPadre = logica.ObtenerOpcionesSistema().Where(a => a.nombre == data.Name).First().opcionId;
            var datosOperaciones = logica.ObtenerOpcionesSistema().Where(a => a.padreId == codigoPadre).ToList();
            ModernTabMenu.Links = new LinkCollection();
            Menu = new LinkCollection();
            datosOperaciones.ToList().ForEach(b => Menu.Add(new Link() { DisplayName = b.nombre, Source = new Uri(b.control, UriKind.Relative) }));
            Menu.ToList().ForEach(a => ModernTabMenu.Links.Add(a));
            ModernTabMenu.SelectedSource = Menu.First().Source;
        }
    }
}
